import { IPSAppDEDataExportItem } from '../../app/dataentity/ipsapp-dedata-export-item';
import { IPSAppDEField } from '../../app/dataentity/ipsapp-defield';
import { IPSAppDataEntity } from '../../app/dataentity/ipsapp-data-entity';
import { IPSCodeList } from '../../codelist/ipscode-list';
import { IPSDataEntity } from '../ipsdata-entity';
import { IPSDEDataExport } from './ipsdedata-export';
import { IPSDEDataExportGroup } from './ipsdedata-export-group';
import { IPSDEDataExportItem } from './ipsdedata-export-item';
import { IPSDEField } from '../defield/ipsdefield';
import { IPSLanguageRes } from '../../res/ipslanguage-res';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEDataExportItemImpl extends PSModelObjectImpl implements IPSDEDataExportItem, IPSAppDEDataExportItem {
  get align(): 'LEFT' | 'CENTER' | 'RIGHT' {
    return this.M.align;
  }

  protected cappslanguageres: IPSLanguageRes | null = null;

  getCapPSLanguageRes(): IPSLanguageRes | null {
    if (this.cappslanguageres != null) return this.cappslanguageres;
    const value = this.M.getCapPSLanguageRes;
    if (value == null) {
      return null;
    }
    this.cappslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getCapPSLanguageRes') as IPSLanguageRes;
    return this.cappslanguageres;
  }

  get capPSLanguageRes(): IPSLanguageRes | null {
    return this.getCapPSLanguageRes();
  }

  getCapPSLanguageResMust(): IPSLanguageRes {
    const value = this.getCapPSLanguageRes();
    if (value == null) {
      throw new Error('未指定标题语言资源');
    }
    return value;
  }

  get caption(): string {
    return this.M.caption;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get defaultValue(): IModel {
    return this.M.defaultValue;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get format(): string {
    return this.M.format;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psappdefield: IPSAppDEField | null = null;

  getPSAppDEField(): IPSAppDEField | null {
    if (this.psappdefield != null) return this.psappdefield;
    const value = this.M.getPSAppDEField;
    if (value == null) {
      return null;
    }
    const ipsappdataentity = this.getParentPSModelObject('app.dataentity.IPSAppDataEntity') as IPSAppDataEntity;
    if (ipsappdataentity != null) {
      this.psappdefield = ipsappdataentity.findPSAppDEField(value);
    }
    return this.psappdefield;
  }

  get psAppDEField(): IPSAppDEField | null {
    return this.getPSAppDEField();
  }

  getPSAppDEFieldMust(): IPSAppDEField {
    const value = this.getPSAppDEField();
    if (value == null) {
      throw new Error('未指定应用实体属性');
    }
    return value;
  }

  protected pscodelist: IPSCodeList | null = null;

  getPSCodeList(): IPSCodeList | null {
    if (this.pscodelist != null) return this.pscodelist;
    const value = this.M.getPSCodeList;
    if (value == null) {
      return null;
    }
    this.pscodelist = this.getPSModel4('codelist.IPSCodeList', value, 'getPSCodeList') as IPSCodeList;
    return this.pscodelist;
  }

  get psCodeList(): IPSCodeList | null {
    return this.getPSCodeList();
  }

  getPSCodeListMust(): IPSCodeList {
    const value = this.getPSCodeList();
    if (value == null) {
      throw new Error('未指定代码表');
    }
    return value;
  }

  protected psdedataexportgroup: IPSDEDataExportGroup | null = null;

  getPSDEDataExportGroup(): IPSDEDataExportGroup | null {
    if (this.psdedataexportgroup != null) return this.psdedataexportgroup;
    const value = this.M.getPSDEDataExportGroup;
    if (value == null) {
      return null;
    }
    const ipsdedataexport = this.getParentPSModelObject('dataentity.dataexport.IPSDEDataExport') as IPSDEDataExport;
    if (ipsdedataexport != null) {
      this.psdedataexportgroup = ipsdedataexport.findPSDEDataExportGroup(value);
    }
    return this.psdedataexportgroup;
  }

  get psDEDataExportGroup(): IPSDEDataExportGroup | null {
    return this.getPSDEDataExportGroup();
  }

  getPSDEDataExportGroupMust(): IPSDEDataExportGroup {
    const value = this.getPSDEDataExportGroup();
    if (value == null) {
      throw new Error('未指定数据导出分组');
    }
    return value;
  }

  protected psdefield: IPSDEField | null = null;

  getPSDEField(): IPSDEField | null {
    if (this.psdefield != null) return this.psdefield;
    const value = this.M.getPSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.psdefield = ipsdataentity.findPSDEField(value);
    }
    return this.psdefield;
  }

  get psDEField(): IPSDEField | null {
    return this.getPSDEField();
  }

  getPSDEFieldMust(): IPSDEField {
    const value = this.getPSDEField();
    if (value == null) {
      throw new Error('未指定实体属性');
    }
    return value;
  }

  get privilegeId(): string {
    return this.M.privilegeId;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get hidden(): boolean {
    return this.M.hidden != null ? this.M.hidden : false;
  }

  get cls(): string {
    return 'PSDEDataExportItemImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'app.dataentity.IPSAppDEDataExportItem' || cls == 'dataentity.dataexport.IPSDEDataExportItem') return true;
    return super.instanceof(cls);
  }
}
